<template>
	<view class="page notice">
		<nav-header title="通知">
			<template v-slot:right>
				<text class="confirm-text" @click="allRead">全部标记已读</text>
			</template>
		</nav-header>

		<!-- <up-cell-group>
			<up-cell is-link title="好友申请" :url="'/pageSubOne/notice/notice-friend'">
				<template #icon>
					<img :src="getResource('/icon/friend.svg')" alt="" class="cell-img" />
				</template>
				<template #value>
					<up-badge class="uni-badge-left-margin" :value="friend" max="99" size="normal" />
				</template>
			</up-cell>
			<up-cell is-link title="群聊申请" :url="'/pageSubOne/notice/notice-group'">
				<template #icon>
					<img :src="getResource('/icon/group-add.svg')" alt="" class="cell-img" />
				</template>
				<template #value>
					<up-badge class="uni-badge-left-margin" :value="group" max="99" size="normal" />
				</template>
			</up-cell>
			<up-cell is-link title="交易通知" :url="'/pageSubOne/notice/notice-deal'">
				<template #icon>
					<img :src="getResource('/icon/deal.svg')" alt="" class="cell-img" />
				</template>
				<template #value>
					<up-badge class="uni-badge-left-margin" :value="deal" max="99" size="normal" />
				</template>
			</up-cell>
			<up-cell is-link title="平台通知" :url="'/pageSubOne/notice/notice-platform'">
				<template #icon>
					<img :src="getResource('/icon/message.svg')" alt="" class="cell-img" />
				</template>
				<template #value>
					<up-badge class="uni-badge-left-margin" :value="system" max="99" size="normal" />
				</template>
			</up-cell>
		</up-cell-group> -->

		<list-contacts type="function" status="contact" :List="noticeList"></list-contacts>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				friend: 0,
				group: 0,
				deal: 0,
				system: 0
				// noticeList: [{
				// 		icon: "friend",
				// 		message: "好友申请",
				// 		path: "/pageSubOne/notice/notice-friend",
				// 		value:this.friend
				// 	},
				// 	{
				// 		icon: "group-add",
				// 		message: "群聊申请",
				// 		path: "/pageSubOne/notice/notice-group",
				// 		value:this.group
				// 	},
				// 	{
				// 		icon: "check",
				// 		message: "交易通知",
				// 		path: "/pageSubOne/notice/notice-deal"
				// 	}, {
				// 		icon: "message",
				// 		message: "平台通知",
				// 		path: "/pageSubOne/notice/notice-platform"
				// 	}
				// ]
			}
		},
		computed: {
			noticeList() {
				return [{
						icon: "好友申请",
						message: "好友申请",
						path: "/pageSubOne/notice/notice-friend",
						value: this.friend
					},
					{
						icon: "群聊申请",
						message: "群聊申请",
						path: "/pageSubOne/notice/notice-group",
						value: this.group
					},
					{
						icon: "check",
						message: "交易通知",
						path: "/pageSubOne/notice/notice-deal",
						value: 0
					},
					{
						icon: "平台消息",
						message: "平台通知",
						path: "/pageSubOne/notice/notice-platform",
						value: this.system
					}
				];
			}
		},
		onShow() {
			this.getNumber()
			this.noticeStore.loadNotice()
		},
		methods: {
			allRead(){
				this.$http({
					url:"/systemMessage/readAllSystemMessages",
					method:"GET"
				}).then(()=>{
					this.getNumber()
					this.noticeStore.loadNotice()
					uni.showToast({
						title:"全部已读~",
						icon:"none"
					})
				})
			},
			getNumber() {
				this.$http({
					url: "/systemMessage/findUnReadSystemMessage",
					method: "GET"
				}).then((data) => {
					console.log(data)
					this.group = data['54']
					this.friend = data['55']
					this.system = data['56']
				})
			}
		}
	}
</script>

<style lang="less" scoped>
	.notice {
		.confirm-text {
			font-size: 25rpx;
			color: #1989FA;
		}

		.cell-img {
			width: 60rpx;
			height: 60rpx;
			margin-right: 10rpx;
		}
	}
</style>